var start = "";
var end = "";
function doSearch() {
	checkSearch();
	
	$('#tt').datagrid('load', {
		groupName : $('#groupName').val(),
		start : start,
		end : end
	});
}

function checkSearch(){
	var startYear = $("#startYear").combobox('getValue');
	var startMonth = $("#startMonth").combobox('getValue');
	var endYear = $("#endYear").combobox('getValue');
	var endMonth = $("#endMonth").combobox('getValue');
	
	if (startYear != "" || startMonth != "") {
		if (startMonth == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
		if (startYear == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
	}
	
	if (endYear != "" || endMonth != "") {
		if (endMonth == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
		if (endYear == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
	}
	
	var startYear = $("#startYear").combobox('getValue');
	var startMonth = $("#startMonth").combobox('getValue');
	var endYear = $("#endYear").combobox('getValue');
	var endMonth = $("#endMonth").combobox('getValue');
	
	if (startYear != "" && startMonth != "") {
		start = startYear + "-" + startMonth;
	}
	if (endYear != "" && endMonth != "") {
		end = endYear + "-" + endMonth;
	}
}

$(function() {
	var date=new Date;
	var year=date.getFullYear(); 
	var month=date.getMonth()+1;
	month =(month<10 ? "0"+month:month); 
	
	$('#startYear').combobox('setValue', year);
	$('#startMonth').combobox('setValue', month);
	$('#endYear').combobox('setValue', year);
	$('#endMonth').combobox('setValue', month);
	
	checkSearch();
	
	$('#tt').datagrid({
		view : detailview,
		detailFormatter : function(index, row) {
			return '<div class="ddv" style="padding:5px 0"></div>';
		},
		onExpandRow : function(index, row) {
			var ddv = $(this).datagrid('getRowDetail', index).find('div.ddv');
			ddv.panel({
				border : false,
				cache : false,
				href : '/new/execution/getSearchData?groupId=' + row.groupId + '&start=' + start + '&end=' + end,
				onLoad : function() {
					$('#tt').datagrid('fixDetailRowHeight', index);
				}
			});
			$('#tt').datagrid('fixDetailRowHeight', index);
		}
	});
});

function sortInfo(a,b){
	var number1 = parseFloat(a);  
	var number2 = parseFloat(b);	   
	return (number1 > number2 ? 1 : -1);    
}

